function phiv = dreumFlow4(H,K,phi,tc,theta,type)				
% Calculate single-period (flow) utility for each site choice 


% Define parameters
eta = [theta(2) theta(3) 0];
chi = theta(6:27);
mu = theta(1);
Nu=size(tc,1);


% Calculate flow utility
phiv = zeros(H+1,K,Nu);

for idx1 = 1:H-1 % PP-only (idx1 = 0) has no chi and tc = 0, so not included in loop
                 % Same for opt-out (idx1 = 23) 
                 
	for idx2 = 1:K

		phi1 = phi(idx1+1,idx2); % Set probability of success
	
		for idx3 = 1:Nu  
             
            tc1 = tc(idx3,idx1);

			phiv(idx1+1,idx2,idx3) = phi1*(chi(idx1) + eta(type) + tc1*mu);
					
		end 
	
	end

end
